package dup.login.demo.queue;

import dup.login.demo.config.RabbitConfig;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;

import java.text.SimpleDateFormat;
import java.util.Date;

@Component
public class RetryProducer {
    @Autowired
    private AmqpTemplate rabbitTemplate;

    public void send1() {
        Date date = new Date();
        String dateString = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
        MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
        params.add("order_id", "100");
        System.out.println("send msg date:" + dateString);
        this.rabbitTemplate.convertAndSend(RabbitConfig.EXCHANGE_NAME, RabbitConfig.ROUTING_KEY, params);
    }
}
